package com.yulongtian.weekCompetition.month202301.week04;

/**
 * 第 329 场周赛
 * 可
 *
 * @author yulongTian
 * @create 2023-01-22 10:21
 */
public class Test01 {
    public static void main(String[] args) {
        System.out.println(alternateDigitSum(886996));
    }

    public static int alternateDigitSum(int n) {
        int index = 0;
        int ans = 0;
        String s = String.valueOf(n);
        int[] fu = new int[]{1, -1};
        while (index < s.length()) {
            ans += fu[index % 2] * (s.charAt(index) - '0');
            index++;
        }
        return ans;
    }

}
